package tencent.music;

/**
 * @author habitplus
 * @problem
 * @desc
 * @link
 * @since 2021-08-26 22:25
 */
public class T20210826N2 {
    public int maxValue (String s, int k) {
        if (s == null || k < 1 || s.length() < 1) {
            return 0;
        }

        char[] chs = s.toCharArray();
        int ans = 0, t = 0;

        int n = chs.length;
        int p = (int) Math.pow(10, k - 1);
        for (int i = 0; i < n; i++) {
            t = t * 10 + (chs[i] - '0');
            if (i >= k - 1) {
                ans = Math.max(ans, t);
                t %= p;
            }
        }

        return ans;
    }

    private int findMaxChar(char[] chs, int l, int r) {
        int k = l;
        for (int i = l + 1; i < r; i++) {
            if (chs[k] < chs[i]) {
                k = i;
            }
        }
        return k;
    }

    public static void main(String[] args) {

        System.out.println(new T20210826N2().maxValue("321", 1));
    }
}
